$.fn.editor=function(options){
	this.attr("contenteditable",true);
	var _options={"width":"600px","height":"200px"};
	this.wrap("<div class='ceditor' style='width:"+_options.width+";margin:0 auto;'></div>");
	this.before("<div class='ceditor_tool'></div>");
	this.css({"height":"200px","background":"#fff","padding":"5px","border":0});
	
	var tools = [
		{command:"copy",value:null,title:"复制"},
		{command:"cut",value:null,title:"剪切"},
		//{command:"delete",value:null,title:"删除"},
		{command:"bold",value:null,title:"加粗"},
		{command:"italic",value:null,title:"斜体"},
		{command:"fontName",value:"Arial",title:"字体样式"},
		{command:"fontSize",value:"20px",title:"字体大小"},
		{command:"foreColor",value:"red",title:"字体颜色"},
		{command:"formatBlock",value:"h1",title:"添加标签"},
		{command:"hiliteColor",value:"red",title:"字体背景"},
		{command:"indent",value:null,title:"缩进"},
		{command:"insertHorizontalRule",value:null,title:"水平线"},
		{command:"insertImage",value:null,title:"图片"},
		{command:"insertOrderedList",value:null,title:"有序列表"},
		{command:"insertUnorderedList",value:null,title:"无序列表"},
		{command:"insertParagraph",value:null,title:"添加段落"},
		{command:"italic",value:null,title:"斜体"},
		{command:"italic",value:null,title:"斜体"},
		{command:"italic",value:null,title:"斜体"},
		{command:"italic",value:null,title:"斜体"},
		{command:"italic",value:null,title:"斜体"},
		{command:"italic",value:null,title:"斜体"},
		{command:"italic",value:null,title:"斜体"},
		{command:"italic",value:null,title:"斜体"},
		{command:"italic",value:null,title:"斜体"},
		{command:"italic",value:null,title:"斜体"},
		{command:"italic",value:null,title:"斜体"},
		{command:"italic",value:null,title:"斜体"},
		{command:"italic",value:null,title:"斜体"},
		{command:"italic",value:null,title:"斜体"},
		{command:"italic",value:null,title:"斜体"},
		{command:"italic",value:null,title:"斜体"},
		{command:"italic",value:null,title:"斜体"},
		{command:"italic",value:null,title:"斜体"},
		{command:"italic",value:null,title:"斜体"},
		{command:"italic",value:null,title:"斜体"},
		{command:"italic",value:null,title:"斜体"},
		{command:"italic",value:null,title:"斜体"},
		{command:"italic",value:null,title:"斜体"},
		{command:"italic",value:null,title:"斜体"},
		{command:"italic",value:null,title:"斜体"},
		{command:"italic",value:null,title:"斜体"},
		{command:"italic",value:null,title:"斜体"},
		{command:"italic",value:null,title:"斜体"},
		{command:"italic",value:null,title:"斜体"},
		{command:"italic",value:null,title:"斜体"},
		{command:"italic",value:null,title:"斜体"}
	]
	
	for(var i=0;i<tools.length;i++){
		$(".ceditor_tool").append("<button class='tool' name='"+tools[i].command+"' data-value='"+tools[i].value+"' title='"+tools[i].title+"'></button>");
	}
	$(".tool").on("click",function(){
		var lab = $(this).attr("name");
		var value = $(this).attr("data-value");
		document.execCommand(lab, false, value);
	})
}
